package com.sun.androidexerciseproject.function.singleInstance;

import android.content.Context;

/**
 * Description:
 * File: DoubleLaySingleInstance.java
 * Author: Administrator
 * Create: 2018/11/29 0029 上午 9:51
 */
public class DoubleLaySingleInstance {
    private static DoubleLaySingleInstance INSTANCE = null;
    private Context mContext;

    private DoubleLaySingleInstance() {

    }

    public static DoubleLaySingleInstance getInstance() {
        if (null == INSTANCE) {
            synchronized (DoubleLaySingleInstance.class) {
                if (null == INSTANCE) {
                    INSTANCE = new DoubleLaySingleInstance();
                }
                return INSTANCE;
            }
        } else {
            return INSTANCE;
        }
    }

    public static DoubleLaySingleInstance getInstance(Context context) {
        if (null == INSTANCE) {
            synchronized (DoubleLaySingleInstance.class) {
                if (null == INSTANCE) {
                    INSTANCE = new DoubleLaySingleInstance();
                }
                INSTANCE.mContext = context;
                return INSTANCE;
            }
        } else {
            return INSTANCE;
        }
    }
}
